package com.bupt.ilink.mapper.userManagement;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bupt.ilink.entity.User;
import com.bupt.ilink.entity.userManagement.UserTeam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface TeamMapper extends BaseMapper<UserTeam> {
    @Update("UPDATE User_team SET team_num = team_num - 1 WHERE team_id = #{teamId}")
    int decrementTeamNum(@Param("teamId") Long teamId);

    @Update("UPDATE User_team SET team_num = team_num + 1 WHERE team_id = #{teamId}")
    int addTeamNum(@Param("teamId") Long teamId);

    @Select("SELECT group_id FROM User_team WHERE team_id = #{teamId}")
    Long findGroupIdByTeamId(Long teamId);

    @Select("SELECT team_type FROM User_team WHERE team_id = #{teamId}")
    String findTeamTypeByTeamId(Long teamId);

}
